package com.example.mybaseapp.ui

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.mybaseapp.R
import com.example.mybaseapp.widget.rotatewheel.SpinningWheelView

class SeondActivity : AppCompatActivity() , SpinningWheelView.OnRotationListener<String>{
    private lateinit var wheelView: SpinningWheelView

    private lateinit var rotate: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_seond)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.activity_main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        wheelView = findViewById(R.id.wheel) as SpinningWheelView

        rotate = findViewById(R.id.rotate) as Button

        wheelView.setItems(R.array.dummy)
        wheelView.setOnRotationListener(this)

        rotate.setOnClickListener(View.OnClickListener { // max angle 50
            // duration 10 second
            // every 50 ms rander rotation
            wheelView.rotate(50F, 3000, 50)
        })
    }

    override fun onRotation() {
        Log.d("XXXX", "On Rotation")
    }

    override fun onStopRotation(item: String?) {
        Toast.makeText(this, item, Toast.LENGTH_LONG).show()
    }
}